package aigle.idm.diagraph.tp3.diagram_default_root.part;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.View;

import aigle.idm.diagraph.tp3.Bouteille;
import aigle.idm.diagraph.tp3.Compose;
import aigle.idm.diagraph.tp3.Ingredient;
import aigle.idm.diagraph.tp3.LivreRecettes;
import aigle.idm.diagraph.tp3.Localisation;
import aigle.idm.diagraph.tp3.Recette;
import aigle.idm.diagraph.tp3.Tp3Package;
import aigle.idm.diagraph.tp3.Vin;

/**
 * @generated
 */
public class Tp3DiagramUpdater {

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor> getSemanticChildren(
			View view) {
		switch (aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LivreRecettesEditPart.VISUAL_ID:
			return getLivreRecettes_79SemanticChildren(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteVinsEditPart.VISUAL_ID:
			return getRecetteVins_5001SemanticChildren(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor> getLivreRecettes_79SemanticChildren(
			View view) {
		if (!view.isSetElement()) {
			return Collections.emptyList();
		}
		LivreRecettes modelElement = (LivreRecettes) view.getElement();
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor>();
		for (Iterator<?> it = modelElement.getRecettes().iterator(); it
				.hasNext();) {
			Recette childElement = (Recette) it.next();
			int visualID = aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getNodeVisualID(view, childElement);
			if (visualID == aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteEditPart.VISUAL_ID) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor(
						childElement, visualID));
				continue;
			}
		}
		for (Iterator<?> it = modelElement.getIngredients().iterator(); it
				.hasNext();) {
			Ingredient childElement = (Ingredient) it.next();
			int visualID = aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getNodeVisualID(view, childElement);
			if (visualID == aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.IngredientEditPart.VISUAL_ID) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor(
						childElement, visualID));
				continue;
			}
		}
		for (Iterator<?> it = modelElement.getVins().iterator(); it.hasNext();) {
			Vin childElement = (Vin) it.next();
			int visualID = aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getNodeVisualID(view, childElement);
			if (visualID == aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.VinEditPart.VISUAL_ID) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor(
						childElement, visualID));
				continue;
			}
		}
		for (Iterator<?> it = modelElement.getDepartements().iterator(); it
				.hasNext();) {
			Localisation childElement = (Localisation) it.next();
			int visualID = aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getNodeVisualID(view, childElement);
			if (visualID == aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor(
						childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor> getRecetteVins_5001SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Recette modelElement = (Recette) containerView.getElement();
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor>();
		for (Iterator<?> it = modelElement.getVins().iterator(); it.hasNext();) {
			Bouteille childElement = (Bouteille) it.next();
			int visualID = aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getNodeVisualID(view, childElement);
			if (visualID == aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.BouteilleEditPart.VISUAL_ID) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3NodeDescriptor(
						childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getContainedLinks(
			View view) {
		switch (aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LivreRecettesEditPart.VISUAL_ID:
			return getLivreRecettes_79ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteEditPart.VISUAL_ID:
			return getRecette_1001ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.IngredientEditPart.VISUAL_ID:
			return getIngredient_1002ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.VinEditPart.VISUAL_ID:
			return getVin_1003ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID:
			return getLocalisation_1004ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.BouteilleEditPart.VISUAL_ID:
			return getBouteille_2001ContainedLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID:
			return getCompose_3001ContainedLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIncomingLinks(
			View view) {
		switch (aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteEditPart.VISUAL_ID:
			return getRecette_1001IncomingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.IngredientEditPart.VISUAL_ID:
			return getIngredient_1002IncomingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.VinEditPart.VISUAL_ID:
			return getVin_1003IncomingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID:
			return getLocalisation_1004IncomingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.BouteilleEditPart.VISUAL_ID:
			return getBouteille_2001IncomingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID:
			return getCompose_3001IncomingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getOutgoingLinks(
			View view) {
		switch (aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
				.getVisualID(view)) {
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteEditPart.VISUAL_ID:
			return getRecette_1001OutgoingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.IngredientEditPart.VISUAL_ID:
			return getIngredient_1002OutgoingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.VinEditPart.VISUAL_ID:
			return getVin_1003OutgoingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.LocalisationEditPart.VISUAL_ID:
			return getLocalisation_1004OutgoingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.BouteilleEditPart.VISUAL_ID:
			return getBouteille_2001OutgoingLinks(view);
		case aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID:
			return getCompose_3001OutgoingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getLivreRecettes_79ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getRecette_1001ContainedLinks(
			View view) {
		Recette modelElement = (Recette) view.getElement();
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_Compose_3001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_Recette_OrigineRegionale_3002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIngredient_1002ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getVin_1003ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getLocalisation_1004ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getBouteille_2001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getCompose_3001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getRecette_1001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIngredient_1002IncomingLinks(
			View view) {
		Ingredient modelElement = (Ingredient) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		result.addAll(getIncomingTypeModelFacetLinks_Compose_3001(modelElement,
				crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getVin_1003IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getLocalisation_1004IncomingLinks(
			View view) {
		Localisation modelElement = (Localisation) view.getElement();
		Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
				.find(view.eResource().getResourceSet().getResources());
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		result.addAll(getIncomingFeatureModelFacetLinks_Recette_OrigineRegionale_3002(
				modelElement, crossReferences));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getBouteille_2001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getCompose_3001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getRecette_1001OutgoingLinks(
			View view) {
		Recette modelElement = (Recette) view.getElement();
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		result.addAll(getContainedTypeModelFacetLinks_Compose_3001(modelElement));
		result.addAll(getOutgoingFeatureModelFacetLinks_Recette_OrigineRegionale_3002(modelElement));
		return result;
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIngredient_1002OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getVin_1003OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getLocalisation_1004OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getBouteille_2001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getCompose_3001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	private static Collection<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getContainedTypeModelFacetLinks_Compose_3001(
			Recette container) {
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		for (Iterator<?> links = container.getComposes().iterator(); links
				.hasNext();) {
			EObject linkObject = (EObject) links.next();
			if (false == linkObject instanceof Compose) {
				continue;
			}
			Compose link = (Compose) linkObject;
			if (aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID != aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			Ingredient dst = link.get_ingredient();
			result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor(
					container,
					dst,
					link,
					aigle.idm.diagraph.tp3.diagram_default_root.providers.Tp3ElementTypes.Compose_3001,
					aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID));
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIncomingTypeModelFacetLinks_Compose_3001(
			Ingredient target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() != Tp3Package.eINSTANCE
					.getCompose__ingredient()
					|| false == setting.getEObject() instanceof Compose) {
				continue;
			}
			Compose link = (Compose) setting.getEObject();
			if (aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID != aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3VisualIDRegistry
					.getLinkWithClassVisualID(link)) {
				continue;
			}
			if (false == link.eContainer() instanceof Recette) {
				continue;
			}
			Recette container = (Recette) link.eContainer();
			result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor(
					container,
					target,
					link,
					aigle.idm.diagraph.tp3.diagram_default_root.providers.Tp3ElementTypes.Compose_3001,
					aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.ComposeEditPart.VISUAL_ID));

		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getIncomingFeatureModelFacetLinks_Recette_OrigineRegionale_3002(
			Localisation target,
			Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences) {
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		Collection<EStructuralFeature.Setting> settings = crossReferences
				.get(target);
		for (EStructuralFeature.Setting setting : settings) {
			if (setting.getEStructuralFeature() == Tp3Package.eINSTANCE
					.getRecette_OrigineRegionale()) {
				result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor(
						setting.getEObject(),
						target,
						aigle.idm.diagraph.tp3.diagram_default_root.providers.Tp3ElementTypes.RecetteOrigineRegionale_3002,
						aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteOrigineRegionaleEditPart.VISUAL_ID));
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	private static Collection<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> getOutgoingFeatureModelFacetLinks_Recette_OrigineRegionale_3002(
			Recette source) {
		LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor> result = new LinkedList<aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor>();
		Localisation destination = source.getOrigineRegionale();
		if (destination == null) {
			return result;
		}
		result.add(new aigle.idm.diagraph.tp3.diagram_default_root.part.Tp3LinkDescriptor(
				source,
				destination,
				aigle.idm.diagraph.tp3.diagram_default_root.providers.Tp3ElementTypes.RecetteOrigineRegionale_3002,
				aigle.idm.diagraph.tp3.diagram_default_root.edit.parts.RecetteOrigineRegionaleEditPart.VISUAL_ID));
		return result;
	}

}
